<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="./css/reset.css">
    <link rel="stylesheet" href="./css/layui/css/layui.css">
    <link rel="stylesheet" href="./css/01-Amy-market.css">
    <title>jiuyelv</title>
</head>

<body>
    <div id="wrap">
        <div class="heardFont">
            <span>就业率统计</span>
        </div>
        <div id="content">
            <div id="header">
                <span class="active">登记量和报名统计</span>
                <span>退单系统</span>
                <span>咨询系统</span>
            </div>
            <div id="middle">
                <span>日期选择：</span>
                <em id="thisMonth" class="active2">本月</em>
                <em id="precedMonth">上月</em>
                <div>
                    <span>选择日期</span>
                    <ul>
                        <input id="day" placeholder="开始日期">
                        -- <input id="day2" placeholder="截止日期">
                    </ul>
                </div>

            </div>
            <table>
                <tr>
                    <th>地区</th>
                    <th>Java</th>
                    <th>Java精英班</th>
                    <th>Web大前端</th>
                    <th>UI视觉设计</th>
                    <th>大数据</th>
                    <th>Python课程</th>
                    <th>Unity3D</th>
                </tr>
            </table>
        </div>
</body>

<script src="./js/jquery-3.4.1.js"></script>
<script src="./css/layui/layui.js"></script>
<script src="./js/01-Amy-market.js"></script>
<script src="./js/url.js"></script>
<script>
    // 页面加载
    $.ajax({
        type: "post",
        url: SetUrl.dataUrl.jiuyelv,
        dataType: "json",
        data: {
            thisMonth: '1'
        },
        success: function (data) {
            console.log(data)
            if (data.code == 100) {
                console.log(data.result)
                var a = data.result;
                $('th').parent().siblings().remove();
                for (var k in a) {
                    $('<tr><td>' + a[k].area + '</td><td>' + a[k].javaCount + '</td><td>' + a[k].javaJyCount + '</td><td>' + a[k].webQdCount + '</td><td>' + a[k].uiCount + '</td><td>' + a[k].bigDataCount + '</td><td>' + a[k].pythonCount + '</td><td>' + a[k].unity3dCount + '</td></tr>').appendTo('table')
                }
            }
        },
        error: function (xhr, error) {
            console.log(error)
        }
    })
    // 本月
    $('#precedMonth').click(function () {
        $.ajax({
            type: "post",
            url: SetUrl.dataUrl.jiuyelv,
            dataType: "json",
            data: {
                precedMonth: '1'
            },
            success: function (data) {
                console.log(data)
                if (data.code == 100) {
                    console.log(data.result)
                    var a = data.result;
                    $('th').parent().siblings().remove();
                    for (var k in a) {
                        $('<tr><td>' + a[k].area + '</td><td>' + a[k].javaCount + '</td><td>' + a[k].javaJyCount + '</td><td>' + a[k].webQdCount + '</td><td>' + a[k].uiCount + '</td><td>' + a[k].bigDataCount + '</td><td>' + a[k].pythonCount + '</td><td>' + a[k].unity3dCount + '</td></tr>').appendTo('table')
                    }
                }
            },
            error: function (xhr, error) {
                console.log(error)
            }
        })
    })
    // 上月
    $('#thisMonth').click(function () {
        $.ajax({
            type: "post",
            url: SetUrl.dataUrl.jiuyelv,
            dataType: "json",
            data: {
                thisMonth: '1'
            },
            success: function (data) {
                console.log(data)
                if (data.code == 100) {
                    console.log(data.result)
                    var a = data.result;
                    $('th').parent().siblings().remove();
                    for (var k in a) {
                        $('<tr><td>' + a[k].area + '</td><td>' + a[k].javaCount + '</td><td>' + a[k].javaJyCount + '</td><td>' + a[k].webQdCount + '</td><td>' + a[k].uiCount + '</td><td>' + a[k].bigDataCount + '</td><td>' + a[k].pythonCount + '</td><td>' + a[k].unity3dCount + '</td></tr>').appendTo('table')
                    }
                }
            },
            error: function (xhr, error) {
                console.log(error)
            }
        })
    })
    $('#day2').click(function () {
        $('#layui-laydate2 td').unbind();
        $('#layui-laydate2 td').click(function () {
            if ($('#day2').val() >= $('#day').val()) {
                $.ajax({
                    type: "post",
                    url: SetUrl.dataUrl.jiuyelv,
                    dataType: "json",
                    data: {
                        'beginTime': $('#day').val(),
                        'endTume': $('#day2').val()
                    },
                    success: function (data) {
                        console.log(data)
                        if (data.code == 100) {
                            console.log(data.result)
                            var a = data.result;
                            $('th').parent().siblings().remove();
                            for (var k in a) {
                                $('<tr><td>' + a[k].area + '</td><td>' + a[k].javaCount + '</td><td>' + a[k].javaJyCount + '</td><td>' + a[k].webQdCount + '</td><td>' + a[k].uiCount + '</td><td>' + a[k].bigDataCount + '</td><td>' + a[k].pythonCount + '</td><td>' + a[k].unity3dCount + '</td></tr>').appendTo('table')
                            }
                        }
                    },
                    error: function (xhr, error) {
                        console.log(error)
                    }
                })
            } else if ($('#day2').val() < $('#day').val()) {
                alert('时间错误')
            }
        })
    })
    $('#day').click(function () {
        $('#layui-laydate1 td').unbind();
        $('#layui-laydate1 td').click(function () {
            if ($('#day2').val() >= $('#day').val()) {
                $.ajax({
                    type: "post",
                    url: SetUrl.dataUrl.jiuyelv,
                    dataType: "json",
                    data: {
                        'beginTime': $('#day').val(),
                        'endTume': $('#day2').val()
                    },
                    success: function (data) {
                        console.log(data)
                        if (data.code == 100) {
                            console.log(data.result)
                            var a = data.result;
                            $('th').parent().siblings().remove();
                            for (var k in a) {
                                $('<tr><td>' + a[k].area + '</td><td>' + a[k].javaCount + '</td><td>' + a[k].javaJyCount + '</td><td>' + a[k].webQdCount + '</td><td>' + a[k].uiCount + '</td><td>' + a[k].bigDataCount + '</td><td>' + a[k].pythonCount + '</td><td>' + a[k].unity3dCount + '</td></tr>').appendTo('table')
                            }
                        }
                    },
                    error: function (xhr, error) {
                        console.log(error)
                    }
                })
            } else if ($('#day2').val() < $('#day').val()) {
                alert('时间错误')
            }
        })
    })
</script>

</html>